[][src]Crate intl_pluralrules

A crate for generating plural rule operands from numberical input.

This crate generates plural operands according to the specifications outlined at Unicode's website.

Input is supported for int, float, and &str.

Examples

Plural rules example for Polish

use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory};
use unic_langid::LanguageIdentifier;

let langid: LanguageIdentifier = "pl".parse().expect("Parsing failed.");

assert!(IntlPluralRules::get_locales(PluralRuleType::CARDINAL).contains(&langid));

let pr = IntlPluralRules::create(langid.clone(), PluralRuleType::CARDINAL).unwrap();
assert_eq!(pr.select(1), Ok(PluralCategory::ONE));
assert_eq!(pr.select("3"), Ok(PluralCategory::FEW));
assert_eq!(pr.select(12), Ok(PluralCategory::MANY));
assert_eq!(pr.select("5.0"), Ok(PluralCategory::OTHER));

assert_eq!(pr.get_locale(), &langid);

Modules

operands

A public AST module for plural rule representations. Plural operands in compliance with CLDR Plural Rules.

Structs

IntlPluralRules

The main structure for selecting plural rules.

Enums

PluralCategory

A public enum for handling the plural category. Each plural category will vary, depending on the language that is being used and whether that language has that plural category.

PluralRuleType

A public enum for handling plural type.

Statics

CLDR_VERSION